<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>用户列表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/Woniu/Public/X-admin/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:29px">ဂ</i> <i class="layui-icon" style="line-height:30px">刷新</i></a>
        </div>
        <div class="x-body">  
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>发件人</th>
                        <th>标题</th>
                        <th>发送时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if(is_array($list)): foreach($list as $key=>$row): ?><tr>
                           <td><?php echo ($row['addresser']); ?></td>
                            <td><?php echo ($row['title']); ?></td>
                            <td><?php echo ($row['sendtime']); ?></td>
                            <td><?php if($row['drafts_id'] == 0): ?><span class="layui-btn layui-btn-success layui-btn-mini">已发布</span><?php else: ?><span class="layui-btn layui-btn-warm layui-btn-mini">草稿</span><?php endif; ?></td>
                            <td class="td-manage">
                                <a title="编辑" href="javascript:;" onclick="admin_edit('修改','/Woniu/index.php/Home/Notice/edit/id/<?php echo ($row['id']); ?>','4','','610')"
                                class="ml-5" style="text-decoration:none"> <i style="font-size:30px;color:#5FB878" class="layui-icon">&#xe642;</i>
                                </a>&nbsp;&nbsp;&nbsp;&nbsp;
                                <a title="删除" href="javascript:;" onclick="admin_del(this,<?php echo ($row['id']); ?>)" style="text-decoration:none">
                                    <i style="font-size: 30px; color: #FF5722;" class="layui-icon">&#xe640;</i>
                                </a>
                            </td>
                        </tr><?php endforeach; endif; ?>
                </tbody>
            </table>
            <div class="total">共<?php echo ($total); ?>条数据</div>
            <div id="pages"></div>

        </div>
        <script src="/Woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8"></script>
        <script src="/Woniu/Public/X-admin/js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use(['laydate','element','laypage','layer','form'], function(){
                $ = layui.jquery;//jquery
              laydate = layui.laydate;//日期插件
              lement = layui.element();//面包导航
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
              var form = layui.form(); //只有执行了这一步，部分表单元素才会修饰成功


              //以上模块根据需要引入
              laypage({
                cont:'pages', //当前id类
                curr:<?php echo ($curr); ?>, //当前页
                groups:5,       //只显示5个按钮后面用...
                pages:<?php echo ($page); ?>,  //总的显示多少页
                skip:true,
                jump:function(obj,first){
                    var url = window.location.href;
                    if(!first){
                        window.location.href=url+"/p/"+obj.curr+".html";
                    }
                }
              });

            });
              

            //批量删除提交
             function delAll () {
                layer.confirm('确认要删除吗？',function(index){
                    //捉到所有被选中的，发异步进行删除
                    layer.msg('删除成功', {icon: 1});
                });
             }
             /*添加*/
            function admin_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }

             /*停用*/
            function admin_stop(obj,id){
                layer.confirm('确认要停用吗？',function(index){
                    //发异步把用户状态进行更改
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="admin_start(this,id)" href="javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-disabled layui-btn-mini">已停用</span>');
                    $(obj).remove();
                    layer.msg('已停用!',{icon: 5,time:1000});
                });
            }

            //编辑
            function admin_edit (title,url,id,w,h) {
                x_admin_show(title,url,w,h); 
            }
            /*删除*/
            function admin_del(obj,id){
            	layer.confirm('确认要删除吗?',function(index){
            		$.post("/Woniu/index.php/Home/Notice/deletes",{id:id},function(data){
            			if(data==1){
            				$(obj).parents("tr").remove();
            				layer.msg('删除成功',{icon:1});                            
            			}else{
            				layer.msg('删除失败',{icon:2});
            			}           		
            		});
            	});
            }

            //页面刷新方法
            function reload() {
                location.replace(location.href);
            }
            </script>
            <script>
        </script>
    </body>
</html>